/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package servlet;

import dao.MemberDao;
import dao.OrderDao;
import entity.Member;
import entity.OrderForm;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/gos")
public class GetOrderServlet extends HttpServlet{

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String name=(String)req.getSession().getAttribute("username");
        Member member=new MemberDao().getMemberByName(name);
        List<OrderForm> list=new ArrayList<>();
        int type=Integer.parseInt(req.getParameter("type"));
        if(type==1){
            list=new OrderDao().getWeekOrder(member.getId());
        }else if(type==2){
             list=new OrderDao().getMonthOrder(member.getId());
        }else if(type==3){
             list=new OrderDao().getHalfyearOrder(member.getId());
        }else if(type==4){
            list=new OrderDao().getCheckedOrder(member.getId());
        }else if(type==5){
            list=new OrderDao().getUncheckedOrder(member.getId());
        }else if(type==6){
            list=new OrderDao().getRatedOrder(member.getId());
        }else{
            list=new OrderDao().getUnratedOrder(member.getId());
        }
        req.setAttribute("list",list);
        req.getRequestDispatcher("/OrderSearchResult.jsp").forward(req,resp);
    }
    
}
